package com.ruoyi.system.service.impl;

import java.util.List;
import java.util.Optional;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.domain.Stock;
import com.ruoyi.system.mapper.StockMapper;
import jdk.nashorn.internal.ir.IfNode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.StocklistMapper;
import com.ruoyi.system.domain.Stocklist;
import com.ruoyi.system.service.IStocklistService;
import com.ruoyi.common.core.text.Convert;

/**
 * 股票列Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-12-26
 */
@Service
public class StocklistServiceImpl  implements IStocklistService
{
    @Autowired
    private StocklistMapper stocklistMapper;

    /**
     * 查询股票列
     * 
     * @param id 股票列主键
     * @return 股票列
     */
    @Override
    public Stocklist selectStocklistById(Long id)
    {
        return stocklistMapper.selectStocklistById(id);
    }

    @Override
    public Stocklist getOne(Stocklist stocklist) {
        return Optional.ofNullable(this.selectStocklistList(stocklist)).map(stocklists ->{
            if (stocklists.size() > 0) {
                return stocklists.get(0);
            }
            return null;
        }).orElse(null);

    }

    /**
     * 查询股票列列表
     * 
     * @param stocklist 股票列
     * @return 股票列
     */
    @Override
    public List<Stocklist> selectStocklistList(Stocklist stocklist)
    {
        return stocklistMapper.selectStocklistList(stocklist);
    }

    /**
     * 新增股票列
     * 
     * @param stocklist 股票列
     * @return 结果
     */
    @Override
    public int insertStocklist(Stocklist stocklist)
    {
        return stocklistMapper.insertStocklist(stocklist);
    }

    /**
     * 修改股票列
     * 
     * @param stocklist 股票列
     * @return 结果
     */
    @Override
    public int updateStocklist(Stocklist stocklist)
    {
        return stocklistMapper.updateStocklist(stocklist);
    }

    /**
     * 批量删除股票列
     * 
     * @param ids 需要删除的股票列主键
     * @return 结果
     */
    @Override
    public int deleteStocklistByIds(String ids)
    {
        return stocklistMapper.deleteStocklistByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除股票列信息
     * 
     * @param id 股票列主键
     * @return 结果
     */
    @Override
    public int deleteStocklistById(Long id)
    {
        return stocklistMapper.deleteStocklistById(id);
    }
}
